package com.winshare.saleAssistant.service.impl;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @Auther zhongziqiang
 * @Date 2020/11/9 下午2:27
 **/

@Slf4j
@Component
public class TestJobImpl {


    /**
     * 1、简单任务示例（Bean模式）
     */
/*    @XxlJob("testJobHandler")
    public void testJobHandler() throws Exception {
        log.info("XXL-JOB, Hello World.");

        for (int i = 0; i < 5; i++) {
            log.info("beat at:" + i);
            TimeUnit.SECONDS.sleep(2);
        }
    }*/

    @XxlJob("testJobHandler")
    public ReturnT<String> execute(String param) throws Exception {
        System.out.println("XXL-JOB, Hello World.");

        for (int i = 0; i < 5; i++) {
//            XxlJobLogger.log("beat at:" + i);
            System.out.println("beat at:" + i);
            TimeUnit.SECONDS.sleep(2);
        }
        return ReturnT.SUCCESS;
    }
}
